<?php
declare(strict_types=1);
namespace Field;

class SysRoleConst
{
    public const pk='';
    public const index=['RoleID'];
	public const fields=['RoleID','ParentRoleID','RoleType','RoleName','Intro','Status'];
	public const comment=['RoleID'=>'','ParentRoleID'=>'上级','RoleType'=>'','RoleName'=>'权限组名字','Intro'=>'角色简介','Status'=>'状态(1:禁用,2:启用)'];
	/*
    * @Field RoleID
    * @Type int(10) unsigned
    * @Collation 
    * @Null NO
    * @Key PRI
    * @Default 
    * @Extra 
    * @Privileges select,insert,update,references
    * @Comment 
    */
    public const RoleID = 'RoleID';
    /*
    * @Field ParentRoleID
    * @Type int(10) unsigned
    * @Collation 
    * @Null NO
    * @Key 
    * @Default 0
    * @Extra 
    * @Privileges select,insert,update,references
    * @Comment 上级
    */
    public const ParentRoleID = 'ParentRoleID';
    /*
    * @Field RoleType
    * @Type int(10)
    * @Collation 
    * @Null YES
    * @Key 
    * @Default 
    * @Extra 
    * @Privileges select,insert,update,references
    * @Comment 
    */
    public const RoleType = 'RoleType';
    /*
    * @Field RoleName
    * @Type varchar(32)
    * @Collation utf8mb4_general_ci
    * @Null YES
    * @Key 
    * @Default 
    * @Extra 
    * @Privileges select,insert,update,references
    * @Comment 权限组名字
    */
    public const RoleName = 'RoleName';
    /*
    * @Field Intro
    * @Type varchar(128)
    * @Collation utf8mb4_general_ci
    * @Null YES
    * @Key 
    * @Default 
    * @Extra 
    * @Privileges select,insert,update,references
    * @Comment 角色简介
    */
    public const Intro = 'Intro';
    /*
    * @Field Status
    * @Type int(10) unsigned
    * @Collation 
    * @Null YES
    * @Key 
    * @Default 0
    * @Extra 
    * @Privileges select,insert,update,references
    * @Comment 状态(1:禁用,2:启用)
    */
    public const Status = 'Status';
}

class SysRoleColumns
{
public  int $RoleID;
   public  int $ParentRoleID;
   public  int $RoleType=0;
   public  ?string $RoleName='';
   public  ?string $Intro='';
   public  int $Status=0;
	public function toArray():array
	{
		return [
'RoleID'=>$this->RoleID,
    'ParentRoleID'=>$this->ParentRoleID,
    'RoleType'=>$this->RoleType,
    'RoleName'=>$this->RoleName,
    'Intro'=>$this->Intro,
    'Status'=>$this->Status,        ];
	}
}

class SysRoleRow
{
	public SysRoleColumns $data;
	public function toArray():array
	{
		return $this->data->toArray();
    }

    public function getValue(string $field):string|int|null
    {
        return match ($field){
        'RoleID' => $this->data->RoleID,
        'ParentRoleID' => $this->data->ParentRoleID,
        'RoleType' => $this->data->RoleType,
        'RoleName' => $this->data->RoleName,
        'Intro' => $this->data->Intro,
        'Status' => $this->data->Status, default=>null
        };
    }

    public function __construct(array $data)
    {
        $this->data = new SysRoleColumns();
        isset($data['RoleID']) && $this->data->RoleID = (int)$data['RoleID'];
           isset($data['ParentRoleID']) && $this->data->ParentRoleID = (int)$data['ParentRoleID'];
           isset($data['RoleType']) && $this->data->RoleType = (int)$data['RoleType'];
           isset($data['RoleName']) && $this->data->RoleName = (string)$data['RoleName'];
           isset($data['Intro']) && $this->data->Intro = (string)$data['Intro'];
           isset($data['Status']) && $this->data->Status = (int)$data['Status'];
    }
}
?>